﻿using System;

namespace TheSnake
{
    public class SnakeBodyElement : MovingObject
    {
        public new const string CollisionGroupString = "snake";

        public SnakeBodyElement(MatrixCoords topLeft, char[,] body, MatrixCoords speed)
            : base(topLeft, body, speed)
        {

        }

        public void UpdateSpeed(MatrixCoords meSpeed) 
        {
            this.Speed = meSpeed; 
        }

        public void SetNewPosition(MatrixCoords newPosition)
        {
            this.TopLeft = newPosition;
        }

        public void SetNewSpeed(MatrixCoords newSpeed)
        {
            this.Speed = newSpeed;
        }

        public override string GetCollisionGroupString()
        {
            return SnakeBodyElement.CollisionGroupString;
        }

        public override void RespondToCollision(CollisionData collisionData)
        {
            if (collisionData.hitObjectsCollisionGroupStrings[0] == "snake")
            {
                Snake.Instance.RespondToCollision(collisionData);
            }
        }
    }
}
